<template>
	<view class="material-measure-content">
		<!-- 门 -->
		<view class="container-main" v-if="Itdoorstate">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>商品名称：</text>
					<text>{{ tradename }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>空间位置：</text>
					<text>{{ positionName }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="showRole()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>类型(门)：</text>
					<text>{{ formData.role }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvueRoleRef" :deepLength="1" @onConfirm="onRoleConfirm" :pickerValueArray="roleArray"></mpvue-picker>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="checkruler()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>复尺状态：</text>
					<text class="right-text">{{ checkruler_name }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvuecheckrulerRoleRef" :deepLength="1" @onConfirm="oncheckrulerConfirm" :pickerValueArray="checkrulerArray"></mpvue-picker>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">材质：</text>
					<input class="right-text" v-model="detailInfo.texture" />
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">门洞高：</text>
					<input class="right-text" v-model="detailInfo.door_high" />
					<text>CM</text>
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">门洞宽：</text>
					<input class="right-text" v-model="detailInfo.door_wide" />
					<text>CM</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-show="doorstate">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">左门边墙厚：</text>
					<input class="right-text" v-model="detailInfo.wall_thickness_l" />
					<text>CM</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-show="doorstate">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">右门边墙厚：</text>
					<input class="right-text" v-model="detailInfo.wall_thickness_r" />
					<text>CM</text>
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">备注：</text>
					<input class="right-text" v-model="detailInfo.note" placeholder="请输入备注" />
				</view>
			</view>
			<view>
				<!-- <text style="font-size: 32upx;">相关图片：</text> -->
				<cus-upload-image :imageList="detailInfo.picture_data" imgTitle="上传图片"></cus-upload-image>
			</view>
			<button style="margin-top: 40upx;" type="primary" @click="establish" v-if="!buttonstate">确定</button>
			<button style="margin-top: 40upx;" type="primary" @click="modifyat" v-if="buttonstate">修改</button>
		</view>

		<!-- 沐浴房 -->
		<view class="container-main" v-if="Itroomstate">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>商品名称：</text>
					<text>{{ tradename }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>空间位置：</text>
					<text>{{ positionName }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">材质：</text>
					<input v-model="detailInfo.texture" class="right-text" />
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="showShower()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>类型：</text>
					<text class="right-text">{{ shower_name }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvueRoleRef" :deepLength="1" @onConfirm="onShowerConfirm" :pickerValueArray="showerArray"></mpvue-picker>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="checkruler()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>复尺状态：</text>
					<text class="right-text">{{ checkruler_name }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvuecheckrulerRoleRef" :deepLength="1" @onConfirm="oncheckrulerConfirm" :pickerValueArray="checkrulerArray"></mpvue-picker>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate"><text>石基处：</text></view>
				<view class="uni-list-cell-navigate flex-grow-3">
					<view class="uni-list-cell-provite " hover-class="uni-list-cell-hover">
						<view class="uni-list-cell-navigate" v-show="arcstate">
							<text class="cus-title-nowrap" style="width: 100upx ;">弧高</text>
							<input v-model="detailInfo.sagitta" class="right-text " />
							<text>CM</text>
						</view>
						<view class="uni-list-cell-navigate" v-show="showerstate">
							<text class="cus-title-nowrap">长：</text>
							<input v-model="detailInfo.long" class="right-text flex-grow-2" />
							<text>CM</text>
						</view>
						<view class="uni-list-cell-navigate" v-show="showerstate">
							<text class="cus-title-nowrap">宽：</text>
							<input v-model="detailInfo.wide" class="right-text flex-grow-2" />
							<text>CM</text>
						</view>
						<view class="uni-list-cell-navigate">
							<input placeholder="两端距离" v-model="detailInfo.both_distance1" class="right-text" />
							<text>CM</text>
						</view>
					</view>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">1米处：</text>
					<input placeholder="两端距离" class="right-text" v-model="detailInfo.both_distance2" />
					<text>CM</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">1.9米处：</text>
					<input placeholder="两端距离" class="right-text" v-model="detailInfo.both_distance3" />
					<text>CM</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">沐浴房高度：</text>
					<input class="right-text" v-model="detailInfo.l_high" />
					<text>CM</text>
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">备注：</text>
					<input class="right-text" v-model="detailInfo.note" placeholder="请输入备注" />
				</view>
			</view>
			<view><cus-upload-image :imageList="detailInfo.picture_data" imgTitle="上传图片"></cus-upload-image></view>
			<button style="margin-top: 40upx;" type="primary" @click="Bathright" v-if="!buttonstate">确定</button>
			<button style="margin-top: 40upx;" type="primary" @click="modifyatBath" v-if="buttonstate">修改</button>
		</view>
		<!-- 浴室柜 -->
		<view class="container-main" v-if="Itcabinetstate">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>商品名称：</text>
					<text>{{ tradename }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>空间位置：</text>
					<text>{{ positionName }}</text>
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">材质：</text>
					<input v-model="detailInfo.texture" class="right-text" />
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="checkruler()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>复尺状态：</text>
					<text class="right-text">{{ checkruler_name }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvuecheckrulerRoleRef" :deepLength="1" @onConfirm="oncheckrulerConfirm" :pickerValueArray="checkrulerArray"></mpvue-picker>
			<view class="uni-list-cell">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">镜面有灯：</text>
					<view>
						<checkbox-group @change="checkboxChange">
							<label v-for="item in checkboxItems" :key="item.name" style="width: 200upx;">
								<view class="distext"><checkbox :value="item.name" :checked="item.checked"></checkbox></view>
								<view class="distext">{{ item.value }}</view>
							</label>
						</checkbox-group>
					</view>
				</view>
			</view>

			<view class="uni-list-cell">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">镜面有储物柜：</text>
					<view>
						<checkbox-group @change="checkcabinetChange">
							<label v-for="item in checkcabinetItems" :key="item.name" style="width: 200upx;">
								<view class="distext"><checkbox :value="item.name" :checked="item.checked"></checkbox></view>
								<view class="distext">{{ item.value }}</view>
							</label>
						</checkbox-group>
					</view>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">预留宽度：</text>
					<input v-model="detailInfo.reserved_distance" class="right-text" />
					<text>CM</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">适用规格：</text>
					<input v-model="detailInfo.apply_distance" class="right-text" disabled="true" />
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">备注：</text>
					<input class="right-text" v-model="detailInfo.note" placeholder="请输入备注" />
				</view>
			</view>
			<view>
				<!-- <text style="font-size: 32upx;">相关图片：</text> -->
				<cus-upload-image :imageList="detailInfo.picture_data" imgTitle="上传图片"></cus-upload-image>
			</view>
			<button style="margin-top: 40upx;" type="primary" @click="cabinetright" v-if="!buttonstate">确定</button>
			<button style="margin-top: 40upx;" type="primary" @click="modifyatCabinet" v-if="buttonstate">修改</button>
		</view>
		<!-- 马桶 -->
		<view class="container-main" v-if="stoolstate">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>商品名称：</text>
					<text>{{ tradename }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>空间位置：</text>
					<text>{{ positionName }}</text>
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">材质：</text>
					<input v-model="detailInfo.texture" class="right-text" />
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="checkruler()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>复尺状态：</text>
					<text class="right-text">{{ checkruler_name }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvuecheckrulerRoleRef" :deepLength="1" @onConfirm="oncheckrulerConfirm" :pickerValueArray="checkrulerArray"></mpvue-picker>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">孔距：</text>
					<input v-model="detailInfo.pitch_row" class="right-text" />
					<text>CM</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">备注：</text>
					<input class="right-text" v-model="detailInfo.note" placeholder="请输入备注" />
				</view>
			</view>
			<view>
				<!-- <text style="font-size: 32upx;">相关图片：</text> -->
				<cus-upload-image :imageList="detailInfo.picture_data" imgTitle="上传图片"></cus-upload-image>
			</view>
			<button style="margin-top: 40upx;" type="primary" @click="stoolright" v-if="!buttonstate">确定</button>
			<button style="margin-top: 40upx;" type="primary" @click="modifystool" v-if="buttonstate">修改</button>
		</view>

		<!-- 橱柜 -->
		<view class="container-main" v-if="Itambry">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>商品名称：</text>
					<text>{{ tradename }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>空间位置：</text>
					<text>{{ positionName }}</text>
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">材质：</text>
					<input v-model="detailInfo.texture" class="right-text" />
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="checkruler()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>复尺状态：</text>
					<text class="right-text">{{ checkruler_name }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvuecheckrulerRoleRef" :deepLength="1" @onConfirm="oncheckrulerConfirm" :pickerValueArray="checkrulerArray"></mpvue-picker>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">备注：</text>
					<input class="right-text" v-model="detailInfo.note" placeholder="请输入备注" />
				</view>
			</view>
			<view>
				<!-- <text style="font-size: 32upx;">相关图片：</text> -->
				<cus-upload-image :imageList="detailInfo.picture_data" imgTitle="上传图片"></cus-upload-image>
			</view>
			<button style="margin-top: 40upx;" type="primary" @click="ambryright" v-if="!buttonstate">确定</button>
			<button style="margin-top: 40upx;" type="primary" @click="modifyambry" v-if="buttonstate">修改</button>
		</view>
		<!-- 衣柜 -->
		<view class="container-main" v-if="Itwardrobe">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>商品名称：</text>
					<text>{{ tradename }}</text>
				</view>
			</view>
			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text>空间位置：</text>
					<text>{{ positionName }}</text>
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">材质：</text>
					<input v-model="detailInfo.texture" class="right-text" />
				</view>
			</view>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="checkruler()">
				<view class="uni-list-cell-navigate" :class="isAdd ? 'uni-navigate-right' : ''">
					<text>复尺状态：</text>
					<text class="right-text">{{ checkruler_name }}</text>
				</view>
			</view>
			<mpvue-picker ref="mpvuecheckrulerRoleRef" :deepLength="1" @onConfirm="oncheckrulerConfirm" :pickerValueArray="checkrulerArray"></mpvue-picker>

			<view class="uni-list-cell" hover-class="uni-list-cell-hover">
				<view class="uni-list-cell-navigate">
					<text class="cus-title-nowrap">备注：</text>
					<input class="right-text" v-model="detailInfo.note" placeholder="请输入备注" />
				</view>
			</view>
			<view>
				<!-- <text style="font-size: 32upx;">相关图片：</text> -->
				<cus-upload-image :imageList="detailInfo.picture_data" imgTitle="上传图片"></cus-upload-image>
			</view>
			<button style="margin-top: 40upx;" type="primary" @click="wardroberight" v-if="!buttonstate">确定</button>
			<button style="margin-top: 40upx;" type="primary" @click="modifywardrobe" v-if="buttonstate">修改</button>
		</view>
	</view>
</template>

<script>
import { doortype, showertype, checkruler } from '../../../common/stateData.js';
export default {
	data() {
		return {
			Itambry: false, //橱柜状态
			Itwardrobe: false, //衣柜状态
			stoolstate: false, // 马桶状态
			buttonstate: false, //按钮状态
			Itdoorstate: false, // 门状态
			Itroomstate: false, // 沐浴房状态
			Itcabinetstate: false, // 浴室柜状态
			doorstate: false, //门选择状态默认为双
			isAdd: false, //是否是新增页面
			imageList: [],
			detailInfo: { picture_data: [] },
			msg: '复尺',
			typestyle: '',
			project_id: null, // 项目ID
			measurement_type: null, // 复尺分类
			product_id: null, // 商品ID
			position_id: null, //位置ID
			hard_product_id: null, //明细行ID
			measurement_id: null, // 复尺列表ID
			tradename: null, // 商品名称
			role_name: '', // 类型（门）选择名称
			roleArray: doortype, //门类型数据
			checkrulerArray: '', // 复尺状态数据
			showerstate: true,
			arcstate: false,
			positionName: null, // 空间位置
			showerArray: showertype,
			checkruler_name: '',
			shower_name: '',
			texturetype: '', // 材质
			formData: {
				role: '', //门类型
				picture_data: [], // 图片
				shower: ''
			},
			checkboxItems: [
				{
					name: '1',
					value: '有',
					checked: false
				}
			],
			checkcabinetItems: [
				{
					name: '1',
					value: '有',
					checked: false
				}
			]
		};
	},
	onLoad(option) {
		this.isAdd = true;
		this.product_id = parseInt(option.product_id);
		this.measurement_type = option.measurement_type;
		this.project_id = parseInt(option.project_id);
		this.hard_product_id = parseInt(option.hard_product_id);
		this.position_id = parseInt(option.position_id);
		this.tradename = option.product_name;
		this.positionName = option.position_name;
		this.detailInfo.texture = option.texture;
		this.detailInfo.apply_distance = option.apply_distance;
		this.customized();
		console.log(this.hard_product_id);

		if (parseInt(option.measurement_id)) {
			this.measurement_id = parseInt(option.measurement_id);
			this.getdoorList(this.measurement_id, this.measurement_type);
			this.buttonstate = true;
		}
		if (this.measurement_type == 'door') {
			this.Itdoorstate = true;
		}
		if (this.measurement_type == 'shower_room') {
			this.Itroomstate = true;
			console.log('沐浴房');
		}
		if (this.measurement_type == 'bathroom_cabinet') {
			this.Itcabinetstate = true;
			console.log('浴室柜');
		}
		if (this.measurement_type == 'closestool') {
			this.stoolstate = true;
			console.log('马桶');
		}
		if (this.measurement_type == 'ambry') {
			this.Itambry = true;
			console.log('橱柜');
		}
		if (this.measurement_type == 'wardrobe') {
			this.Itwardrobe = true;
			console.log('衣柜');
		}
	},
	methods: {
		// 选择镜面是否有灯
		checkboxChange: function(e) {
			var checked = e.target.value;

			var changed = {};
			for (var i = 0; i < this.checkboxItems.length; i++) {
				if (checked.indexOf(this.checkboxItems[i].name) !== -1) {
					this.detailInfo.is_light = true;
				} else {
					this.detailInfo.is_light = false;
				}
			}
			console.log(this.detailInfo.is_light);
		},
		// 选择镜面是储物柜
		checkcabinetChange: function(e) {
			var checked = e.target.value;

			var changed = {};
			for (var i = 0; i < this.checkcabinetItems.length; i++) {
				if (checked.indexOf(this.checkcabinetItems[i].name) !== -1) {
					this.detailInfo.is_cabinet = true;
				} else {
					this.detailInfo.is_cabinet = false;
				}
			}
		},
		// 复尺状态选择器
		checkruler() {
			if (this.isAdd) {
				this.$refs.mpvuecheckrulerRoleRef.show();
			}
		},
		oncheckrulerConfirm(e) {
			this.detailInfo.checkrule = e.value[0];
			this.checkruler_name = e.label;
			console.log(this.detailInfo.checkrule);
		},
		//沐浴房类型选择器
		showShower() {
			if (this.isAdd) {
				this.$refs.mpvueRoleRef.show();
			}
		},

		//沐浴房类型确认
		onShowerConfirm(e) {
			this.detailInfo.sr_type = e.value[0];
			this.shower_name = e.label;

			if (this.detailInfo.sr_type == 'C' || this.detailInfo.sr_type == 'D') {
				this.arcstate = true;
				this.showerstate = false;
			}
			if (this.detailInfo.sr_type == 'ONE') {
				this.arcstate = this.showerstate = false;
			}
			if (this.detailInfo.sr_type == 'L') {
				this.arcstate = false;
				this.showerstate = true;
			}
		},
		//显示门类型选择器
		showRole() {
			if (this.isAdd) {
				this.$refs.mpvueRoleRef.show();
			}
		},
		//门类型确认
		onRoleConfirm(e) {
			this.detailInfo.door_type = e.value[0];
			this.formData.role = e.label;
			if (this.detailInfo.door_type == 'unilateral') {
				this.doorstate = true;
			} else {
				this.doorstate = false;
			}
			console.log(this.formData.role);
		},
		acquirePaths(paths) {
			this.detailInfo.picture_data = paths;
		},
		// 定制状态
		customized() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/measurement_state_search',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {},
				success: res => {
					if (res.data.code === 1) {
						this.checkrulerArray = res.data.data.info;
						console.log(res.data.data.info);
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},

		establish() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_create',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					project_id: this.project_id,
					product_id: this.product_id,
					hard_product_id: this.hard_product_id,
					position_id: this.position_id,
					measurement_type: this.measurement_type,
					door_type: this.detailInfo.door_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					door_high: parseFloat(this.detailInfo.door_high),
					door_wide: parseFloat(this.detailInfo.door_wide),
					wall_thickness_l: parseFloat(this.detailInfo.wall_thickness_l),
					wall_thickness_r: parseFloat(this.detailInfo.wall_thickness_r),
					picture_data: this.detailInfo.picture_data,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '创建成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 3000
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		Bathright() {
			// 沐浴房复尺创建
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_create',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					project_id: this.project_id,
					product_id: this.product_id,
					hard_product_id: this.hard_product_id,
					position_id: this.position_id,
					measurement_type: this.measurement_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					sr_type: this.detailInfo.sr_type,
					long: this.detailInfo.long,
					wide: this.detailInfo.wide,
					sagitta: this.detailInfo.sagitta,
					both_distance1: this.detailInfo.both_distance1,
					both_distance2: this.detailInfo.both_distance2,
					both_distance3: this.detailInfo.both_distance3,
					l_high: this.detailInfo.l_high,
					state_id: this.detailInfo.checkrule
					/* 	m_high: this.detailInfo.m_high,
					r_high: this.detailInfo.r_high */
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '创建成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 3000
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		// 浴室柜复尺创建
		cabinetright() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_create',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					project_id: this.project_id,
					product_id: this.product_id,
					hard_product_id: this.hard_product_id,
					position_id: this.position_id,
					measurement_type: this.measurement_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					is_light: this.detailInfo.is_light,
					is_cabinet: this.detailInfo.is_cabinet,
					reserved_distance: this.detailInfo.reserved_distance,
					apply_distance: this.detailInfo.apply_distance,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '创建成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 3000
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		// 马桶复尺创建
		stoolright() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_create',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					project_id: this.project_id,
					product_id: this.product_id,
					hard_product_id: this.hard_product_id,
					position_id: this.position_id,
					measurement_type: this.measurement_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					pitch_row: parseFloat(this.detailInfo.pitch_row),
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '创建成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 3000
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		// 橱柜复尺创建
		ambryright() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_create',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					project_id: this.project_id,
					product_id: this.product_id,
					hard_product_id: this.hard_product_id,
					position_id: this.position_id,
					measurement_type: this.measurement_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '创建成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 3000
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},

		// 衣柜复尺创建
		wardroberight() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_create',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					project_id: this.project_id,
					product_id: this.product_id,
					hard_product_id: this.hard_product_id,
					position_id: this.position_id,
					measurement_type: this.measurement_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '创建成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 3000
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},

		// 橱柜复尺修改
		modifywardrobe() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_write',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					measurement_id: this.measurement_id,
					measurement_type: this.measurement_type,
					door_type: this.detailInfo.door_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '修改成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		// 橱柜复尺修改
		modifyambry() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_write',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					measurement_id: this.measurement_id,
					measurement_type: this.measurement_type,
					door_type: this.detailInfo.door_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '修改成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},

		// 马桶复尺修改
		modifystool() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_write',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					measurement_id: this.measurement_id,
					measurement_type: this.measurement_type,
					door_type: this.detailInfo.door_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					pitch_row: parseFloat(this.detailInfo.pitch_row),
					picture_data: this.detailInfo.picture_data,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '修改成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		modifyat() {
			// 门修改复尺
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_write',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					measurement_id: this.measurement_id,
					measurement_type: this.measurement_type,
					door_type: this.detailInfo.door_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					door_high: parseFloat(this.detailInfo.door_high),
					door_wide: parseFloat(this.detailInfo.door_wide),
					wall_thickness_l: parseFloat(this.detailInfo.wall_thickness_l),
					wall_thickness_r: parseFloat(this.detailInfo.wall_thickness_r),
					picture_data: this.detailInfo.picture_data,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '修改成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		// 沐浴房修改复尺
		modifyatBath() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_write',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					measurement_id: this.measurement_id,
					measurement_type: this.measurement_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					sr_type: this.detailInfo.sr_type,
					long: this.detailInfo.long,
					wide: this.detailInfo.wide,
					sagitta: this.detailInfo.sagitta,
					both_distance1: this.detailInfo.both_distance1,
					both_distance2: this.detailInfo.both_distance2,
					both_distance3: this.detailInfo.both_distance3,
					l_high: this.detailInfo.l_high,
					m_high: this.detailInfo.m_high,
					r_high: this.detailInfo.r_high,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '修改成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		// 浴室柜复尺修改
		modifyatCabinet() {
			uni.request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_write',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					measurement_id: this.measurement_id,
					measurement_type: this.measurement_type,
					texture: this.detailInfo.texture,
					note: this.detailInfo.note,
					picture_data: this.detailInfo.picture_data,
					is_light: this.detailInfo.is_light,
					is_cabinet: this.detailInfo.is_cabinet,
					reserved_distance: this.detailInfo.reserved_distance,
					apply_distance: this.detailInfo.apply_distance,
					state_id: this.detailInfo.checkrule
				},
				success: res => {
					if (res.data.code === 1) {
						uni.showToast({
							title: '修改成功',
							icon: 'none',
							duration: 3000,
							success: res => {
								this.ReturnSuperiors();
							}
						});
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		// 返回上级
		ReturnSuperiors() {
			this.$eventBus.$emit('measureComplete');
			uni.navigateBack({
				delta: 1
			});
		},
		// 获取l详情
		getdoorList(measurement_id, measurement_type) {
			uni.showLoading({
				title: '',
				mask: false
			});
			this.$request({
				url: this.$store.state.baseUrl + '/lwj/material_measurement_info',
				method: 'POST',
				header: {
					token: this.$store.state.token
				},
				data: {
					measurement_id: measurement_id,
					measurement_type: measurement_type
				},
				success: res => {
					uni.hideLoading();
					if (res.data.code === 1) {
						this.detailInfo = res.data.data.list;
						this.imageList = res.data.data.list.picture_data.map(item => item.imgurl);
						// 类型为门时的,转化
						if (this.detailInfo.door_type) {
							if (this.detailInfo.door_type == 'double_chock') {
								this.formData.role = '预留门边';
							}
							if (this.detailInfo.door_type == 'unilateral') {
								this.formData.role = '单边直墙';
								this.doorstate = true;
							} else {
								this.doorstate = false;
							}
							if (this.detailInfo.door_type == 'bilateral') {
								this.formData.role = '双边直墙';
							}
						}

						// 类型为沐浴房时
						if (this.detailInfo.sr_type) {
							if (this.detailInfo.sr_type == 'L') {
								this.shower_name = 'L型';
							}
							if (this.detailInfo.sr_type == 'C') {
								this.shower_name = '圆弧型';
							}
							if (this.detailInfo.sr_type == 'D') {
								this.shower_name = '钻石型';
							}
							if (this.detailInfo.sr_type == 'ONE') {
								this.shower_name = '一字型';
							}
							if (this.detailInfo.sr_type == 'C' || this.detailInfo.sr_type == 'D') {
								this.arcstate = true;
								this.showerstate = false;
							}
							if (this.detailInfo.sr_type == 'ONE') {
								this.arcstate = this.showerstate = false;
							}
							if (this.detailInfo.sr_type == 'L') {
								this.arcstate = false;
								this.showerstate = true;
							}
						}
						// 浴室柜
						if (this.measurement_type == 'bathroom_cabinet') {
							// 是否 镜面有灯
							if (this.detailInfo.is_light == true) {
								this.checkboxItems[0].checked = true;
							} else {
								this.checkboxItems[0].checked = false;
							}
							// 是否 镜面有储物柜
							if (this.detailInfo.is_cabinet == true) {
								this.checkcabinetItems[0].checked = true;
							} else {
								this.checkcabinetItems[0].checked = false;
							}
						}

						if (this.detailInfo.state_id) {
							switch (this.detailInfo.state_id) {
								case 1:
									this.checkruler_name = '待复尺';
									break;
								case 2:
									this.checkruler_name = '已复尺';
									break;
								case 3:
									this.checkruler_name = '复尺已审核';
									break;
								case 4:
									this.checkruler_name = '定制设计';
									break;
								case 5:
									this.checkruler_name = '设计已复核';
									break;
								case 6:
									this.checkruler_name = '定制已下单';
									break;
								case 7:
									this.checkruler_name = '已拆单';
									break;
								case 8:
									this.checkruler_name = '材料已到位';
									break;
								case 9:
									this.checkruler_name = '生产中';
									break;
								case 10:
									this.checkruler_name = '已包装';
									break;
								case 11:
									this.checkruler_name = '已装车';
									break;
							}
						}
					}
				},
				fail: () => {},
				complete: () => {}
			});
		},
		//图片预览
		previewImage(url) {
			//有图片的时候才能让他弹出来
			if (url !== '') {
				const imgList = [url];
				uni.previewImage({
					// current: imgList[i],
					current: 0,
					urls: imgList
				});
			} else {
				uni.showToast({
					title: '暂无图片',
					mask: false,
					duration: 1500,
					icon: 'none'
				});
			}
		}
	}
};
</script>

<style scoped>
.material-measure-content {
	padding: 20upx 20upx;
	background-color: #ffffff;
	width: 100%;
}

.material-measure-content .material-measure-view {
	font-size: 32upx;
	height: 80upx;
	line-height: 80upx;
}

.material-measure-content view text:nth-of-type(1) {
	color: #8f8f94;
}

.material-measure-content view text:nth-child(2) {
	padding-left: 20upx;
}

.material-measure-remark {
	display: flex;
	align-items: center;
}
.right-text {
	text-align: right;
}
.distext {
	display: inline-block;
}
.uni-list-cell-provite {
	flex-direction: column;
}
.flex-grow-3 {
	flex-grow: 3;
}
.flex-grow-2 {
	flex-grow: 2;
}
.uni-navigate-padding {
	padding: 22upx 10upx;
}
.input-sty {
	width: 60upx;
	padding: 0 10upx;
	display: inline-block;
	vertical-align: -16upx;
}
.uni-height-content {
	width: 100%;
	text-align: center;
}
.uni-height-content .uni-height-content-sty {
	width: 30%;
	display: inline-block;
	border-right: 1upx solid #eaeaea;
}
.uni-height-content .uni-height-content-sty:last-child {
	border: 0;
}
</style>
